home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 6511 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  9.4 KB

  1. Path: news.NetVision.net.il!news
  2. From: Jack <avilev@netvision.net.il>
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Re: 680X0 -> PPC translator?
  5. Date: Fri, 29 Mar 1996 09:10:35 -0800
  6. Organization: NetVision LTD.
  7. Message-ID: <315C198B.49C2@netvision.net.il>
  8. References: <3143E4EB.7303@sapiens.com> <volker.0fsu@vb.franken.de> <31499F8E.26A9@netvision.net.il> <volker.0fw1@vb.franken.de> <315800D7.1854@sapiens.com> <volker.0g32@vb.franken.de>
  9. NNTP-Posting-Host: ts002p9.pop4a.netvision.net.il
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0b6a (Win16; I)
  14.  
  15. Hi Volker, well i'll try to keep the lines shorter this time
  16. so you'll be able to read the text more conveniently and who
  17. know. you might actually be convinced that 680x0 -> PPC is possible. ;-)
  18. well let's do battle....;-)
  19. Volker Barthelmann wrote:
  20. > Avi L. (avil@sapiens.com) wrote:
  21. > : Volker Barthelmann wrote:
  22. > Once an external function is called almost all information becomes useless,
  23. > because You don't know what memory it changes.
  24.  
  25. ok, but i'm assuming the library is already PPC translated so if 
  26. it does any self-modifying tricks, the code will already be translated
  27. and in the correct size. all i care about is that point anyway, if it
  28. uses the area as a data region then i don't care what it does with it
  29. since the data is the same size regardless of the processor used to
  30. manipulate it.
  31.  
  32. > : if you perform careful analysis of the pointers, and that means following the changes made
  33. > : to them by the program, you CAN know in which context they are being used and act
  34. > : appropriatly. for example:
  35. > Perhaps You can perform this analysis. An algorithm can't.
  36.  
  37. why the hell not, if i can understand assembly source code, 
  38. the machine can understand machine code right?! 
  39. and we already know what we're looking for, (variations in 
  40. memory segments which are later used for code execution).
  41. if you know the machine op-codes well enough writing an
  42. algorithm is pretty much straight forward.
  43. > : call _malloc ; let's say register a1 holds the returned address.
  44. > : move a1,xyz(a7) ; store it in some variable, noting the current value of a7.
  45. > Of course You can have a structure holding all Your variables. Now You pass
  46. > the address of this structure to an external function that writes some
  47. > values into it and You lost.
  48.  
  49. i don't seem to care about that, get it through your head, i'm NOT 
  50. going to intervene with what the program does with any memory area, 
  51. just as long as this memory area is not later being used for code
  52. execution. then, and only then will i have to turn to all the locations
  53. where that pointer could have been assigned and then change the size
  54. argument which i already know to the appropriate sizes, once i figure
  55. out that the area is code, i will perform a well defined series of actions
  56. to resolve ALL dependecies related to that area, including size, write loops etc.
  57.  
  58. > : what i mean is, you use your own value of a7 with an initial value of 0 and follow the
  59. > : changes made to it resetting it to 0 on assignments. that way you don't need the actual value
  60. > : of a7 for knowning to which variable it refers to. now you know the address of the pointer to
  61. > : the allocated block i just malloc()'ed so you can know how it's being used later, eg. code or data.
  62. > : and bear in mind that all memory allocation routines call evantually AllocMem() function so you
  63. > There are several memory allocating functions or other functions You can't
  64. > know anything about.
  65.  
  66. then you take into account all of the various SYSTEM functions which allocate 
  67. memory (there aren't many of them) and proceed as normal.
  68.  
  69. > : have the instruction address of where exactly the memory region was allocated and so you can change
  70. > : the size argument for the function if that memory area is later used for self-modifying code.
  71. > : also you have to follow any loops which do writes to the area cuz these might be the sections
  72. > : that copy code into that area and so you have to make the adjustments so that they loop
  73. > : according to the translated code size.
  74. > You would have to adjust EVERYTHING that is in any way dependant on the code
  75. > size! How are You going to do this?
  76.  
  77. all you have to look for is where it was allocated and where it is copied,
  78. assuming you're copying code that is. quite easily done if you follow the 
  79. change made to that pointer while 'running' through the program's logic.
  80.  
  81. > : > : from some outside source, such as malloc(), then you don't have it obviously but that being said
  82. > : > : doesn't imply it's impossible to figure out in which context the address is being used (ie code
  83. > : >
  84. > : > Easy??
  85. > :
  86. > : yes easy, cuz as i said you know where it was allocated and you can change the appropriate
  87. > : argument.
  88. > Er..have You ever really programmed anything with data flow analysis?well actually yes, i did, although it wasn't anywhere near as complex 
  89. as the problem we're talking about. 
  90.  
  91. > : > And in many programs You won't find any call to e.g. AllocMem with this
  92. > : > size at all, because the program uses its own memory-pool-routines.
  93. > : > Etc. etc...
  94. > :
  95. > : but then again it must have allocated the master pool from which it sub-allocates memory from
  96. > : and besides it must pass that allocator the required size, so you can change it if that segment
  97. > : is later used for code, you know the size of the copied code after all and if the size passed to
  98. > : the function is sufficient for the translated code then you don't have to do anything otherwise
  99. > : change it.
  100. > As the size of the sub-allocated memory changes You may have to completely
  101. > rewrite the pool-allocator, because it may depend on the allocations being
  102. > of certain sizes or a multiple of a certain sizes etc.
  103. > To do this the translator would have to completely understand the allocator
  104. > and this is impossible.
  105.  
  106. what???? all you have to do is request the allocator for more memory, no need
  107. to change anything in the allocator itself. the only possible problem i see here
  108. is when the size argument would not be passed through the stack but by some global
  109. variable the program sets just before calling it, but even that is possible to solve
  110. by looking at a few calls to that allocator and discern the calling convention used.
  111. surely the allocator is used more than once in the program.
  112.  
  113. > : > It's not unfounded, but I've thought about some things.
  114. > : > There are much simpler similar problems that are AFAIK proven to be
  115. > : > undecidable.
  116. > :
  117. > : care to elaborate on this please.
  118. > I think most standard data flow problems can only be approximated, but exact
  119. > solutions (which would be needed by Your approach) can not be found.
  120. > AFAIR I read somewhere that this was proven for some cases, but unfortunately
  121. > I don't remember where it was.
  122.  
  123. granted, you're right about that not all solutions are clear cut but when it comes
  124. to exact sciences such as computer-science then i would disagree, especially
  125. since the problem we're dealing with isn't related to any human logic, that
  126. field even in computer-science hasn't been fully explored and understood yet.
  127. no, the only major problem is self-modification of the program otherwise you
  128. translate the code 1:1.
  129.  
  130. > : what the hell does recursion have to do with anything, it simply calls the function from within
  131. > : itself, so what??? if you follow the changes to a7, then you'll always point to the right address,
  132. > : remember that auto-variables don't exist cuz the programs is not running and so all references are
  133. > : are register (a7) indirect and so nothing really matters, you use registers not absolute addresses.
  134. > You seem to think that every program uses variables and registers in the same
  135. > way like a certain compiler. This is not true.
  136.  
  137. a variable is just another location in memory, the compiler has nothing 
  138. to do with its implementation, HUH.
  139.  
  140. > : gimme one example where i would fail to translate that. believe me it should fine.
  141. > I gave several examples. The discussion is rather pointless as long as You
  142. > just say 'I keep track of this' and 'adjust that according to xyz' etc.
  143. > Of course it's possible to rewrite a program to PPC, but You have to show
  144. > that this can be done by an algorithm and this is a different story.
  145. >well saying that often doesn't mean it's wrong and it would be foolish not
  146. to explore every suggested solution. if you are so convinced it is not
  147. possible then surely you can provide me with a concrete proof to undermine
  148. my theory, can't you?! remember the burden of proof lies on my shoulders
  149. cuz i claim something is possible, so you have to give me an example
  150. i can't solve with my theory.
  151.  
  152. > Once You describe Your algorithm I will happily give You an example.
  153.  
  154. the algorithm mainly revolves around self-modification, otherwise it's
  155. a simple translation of code instructions. and my algorithm, though wasn't
  156. presented in a flow-chart, is presented by words. that doesn't mean it's impossible
  157. to write an actual algorithm in a true sense of the word.
  158.  
  159. > But believe me it will never ever work for anything more than some special
  160. > programs. Data flow analysis can be useful for many things, but there are
  161. > severe limitations and Your approach would practically have to 'understand'
  162. > the program and completely rewrite it.
  163. > This is completely absolutely impossible. No chance. Never. Won't work.
  164.  
  165. AH, but that's what i had said before, and really, it is possible, stop being
  166. so passimistic, and start being constructive. besides, most application programs
  167. do conventional programming, so even if it's limited to them, it still has
  168. great value.
  169.  
  170. Avi Lev.
  171.